@echo off

setlocal

set name=%~1
if "%name%"=="" (
    goto :%lan% 1
)

set pid=%~2
if "%pid%"=="" (
    goto :%lan% 3
)

REM set vid=%~3
REM if "%vid%"=="" (
    REM goto :%lan% 2
REM )

set type=%~3
if "%type%"=="" set type=script

set lan=%local_lan%
if "%lan%"=="" set lan=zh 

REM call %~dp0find_device.bat %vid% %pid%
call %~dp0find_device.bat %pid%
if %errorlevel%==0 (
    if %type%==script call :%lan% 0
    exit /b 0
) else (
    if %type%==script call :%lan% 404
    exit /b 404
)

:zh
chcp 65001 >nul
if %~1==0 (
    echo 发现设备[%name%].
)
if %~1==1 (
    echo 设备名称没有设置.
)
if %~1==2 (
    echo vid没有设置.
)
if %~1==3 (
    echo pid没有设置.
)
if %~1==404 (
    echo 没有发现设备[%name%]，请确认已经插入设备[%name%]
)
exit /b %~1


:en
if %~1==0 (
    echo found [%name%].
)
if %~1==1 (
    echo device name not set.
)
if %~1==2 (
    echo vid not set.
)
if %~1==3 (
    echo pid not set.
)
if %~1==404 (
    echo No device [%name%] found, please confirm that the device [%name%] has been inserted.
)
exit /b %~1